<?php
/**
 * CreateUser: zlh
 * CreateTime: 2022/1/21 15:28
 * Remark:
 */

namespace App\Scopes;

use App\Func\TokenFuc;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Scope;

class DbHandleScope implements Scope
{
    public function apply(Builder $builder, Model $model)
    {
        // TODO
//        $companyId = TokenFuc::getCurrentStaffInfo()['company_id'] ?? 66;
        # 获取查看范围权限
        # 公司 A->B
        # 通过当前登录用户获取A公司的所有下级公司ID
//        # a b
//        $builder->where(function ($query){9
//            $query->orWhere('company_id',213);
//            $query->orWhere('company_id',213);
//        });
//        $builder->whereIn('company_id',[888,999]);
    }
}